import router from '@/router';

/**
 * 跳转
 * @param name 路由名称
 * @param params 参数
 * @param tabBar 是否tabBar
 * @param redirect 是否关闭当前页
 */
export function handleJump(name, params = {}, tabBar = false, redirect = false) {
	if (tabBar === true) {
		router.replaceAll({ name: name, params: params });
	} else {
		if (redirect === true) {
			router.replace({ name: name, params: params });
		} else {
			console.log(params);
			router.push({ name: name, params: { username: 'eduardo' } })
		}
	}
}
/**
 * 返回上一页
 * @param timeout
 */
export function goBack(timeout = 1000) {
	setTimeout(() => {
			router.back();
	}, timeout);
}